########################################
# Handlers for restarting services
#

- name: restart auditd
  action: service name=auditd state=restarted

- name: restart apache
  command: /usr/local/bin/conditional-restart.sh httpd httpd

- name: reload apache
  action: service name=httpd state=reloaded

- name: restart collectd
  action: service name=collectd state=restarted

- name: restart crond
  action: service name=crond state=restarted

- name: restart fedmsg-gateway
  command: /usr/local/bin/conditional-restart.sh fedmsg-gateway fedmsg-gateway

- name: restart fedmsg-hub
  command: /usr/local/bin/conditional-restart.sh fedmsg-hub fedmsg-hub

- name: restart fedmsg-irc
  command: /usr/local/bin/conditional-restart.sh fedmsg-irc fedmsg-irc

- name: restart fedmsg-relay
  command: /usr/local/bin/conditional-restart.sh fedmsg-relay fedmsg-relay

- name: restart httpd
  command: /usr/local/bin/conditional-restart.sh httpd httpd

- name: reload httpd
  action: service name=httpd state=reloaded

- name: restart iptables
  action: service name=iptables state=restarted

- name: restart jenkins
  action: service name=jenkins state=restarted

- name: restart kojid
  action: service name=kojid state=restarted

- name: restart libvirtd
  action: service name=libvirtd state=restarted

- name: restart lighttpd
  action: service name=lighttpd state=restarted

- name: restart mailman
  action: service name=mailman state=restarted

- name: restart named
  action: service name=named state=restarted

- name: restart nfs
  action: service name=nfs state=restarted

- name: restart nfslock
  action: service name=nfslock state=restarted

- name: restart ntpd
  action: service name=ntpd state=restarted

- name: restart openvpn (Fedora)
  when: ansible_distribution == "Fedora"
  action: service name=openvpn@openvpn state=restarted

- name: restart openvpn (RHEL6)
  when: ansible_distribution == "RedHat" and ansible_distribution_major_version == "6"
  action: service name=openvpn state=restarted

- name: restart openvpn (RHEL7)
  when: ansible_distribution == "RedHat" and ansible_distribution_major_version == "7"
  action: service name=openvpn@openvpn state=restarted

- name: restart postfix
  action: service name=postfix state=restarted

- name: restart rpcbind
  action: service name=rpcbind state=restarted

- name: restart rpcidmapd
  action: service name=rpcidmapd state=restarted

- name: restart rsyslog
  action: service name=rsyslog state=restarted

- name: restart sshd
  action: service name=sshd state=restarted

- name: restart xinetd
  action: service name=xinetd state=restarted

- name: restart netapproute
  action: command /etc/sysconfig/network-scripts/ifup-routes eth1

- name: restart network
  action: service name=network state=restarted

- name: restart unbound
  action: service name=unbound state=restarted

- name: rebuild postfix transport
  command: /usr/sbin/postmap /etc/postfix/transport

- name: restart glusterd
  service: name=glusterd state=restarted

- name: restart supervisord
  service: name=supervisord state=restarted

- name: run rkhunter
  command: rkhunter --propupd

- name: restart moksha-hub
  service: name=moksha-hub state=restarted

- name: restart dhcpd
  service: name=dhcpd state=restarted

- name: restart memcached
  service: name=memcached state=restarted

- name: reload systemd
  command: systemctl daemon-reload

- name: restart nagios
  shell: nagios -v /etc/nagios/nagios.cfg && systemctl restart nagios

- name: restart bridge
  shell: /usr/lib/systemd/systemd-sysctl --prefix=/proc/sys/net/bridge

- name: hup libvirtd
  command: pkill -HUP libvirtd
  ignore_errors: true
  when: inventory_hostname.startswith('buildhw')

- name: restart fcomm-cache-worker
  service: name=fcomm-cache-worker state=restarted
